import http from '@/api';
import { ADMIN_MODULE } from '@/api/helper/prefix';

/**
 * 获取消息列表
 * @param params
 * @returns {*}
 */
export const getMsgList = (params: any) => {
  return http.get(ADMIN_MODULE + `/sys-message`, params);
};

/**
 * 添加消息
 * @param params
 * @returns {*}
 */
export const addMsg = (params: any) => {
  return http.post(ADMIN_MODULE + `/sys-message`, params);
};

/**
 * 修改消息
 * @param params
 * @returns {*}
 */
export const editMsg = (params: any) => {
  return http.put(ADMIN_MODULE + `/sys-message`, params);
};

/**
 * 删除消息
 * @param params
 * @returns {*}
 */
export const deleteMsg = (params: { ids: number[] }) => {
  return http.delete(ADMIN_MODULE + `/sys-message`, params);
};

/**
 * 获取单个消息
 * @param params
 * @returns {*}
 */
export const getDetileMsg = (params: { roleId: number }) => {
  return http.get(ADMIN_MODULE + `/sys-message/menu`, params);
};
/**
 * 获取分类消息
 * @param params
 * @returns {*}
 */
export const getClassifiedMsg = params => {
  return http.get(ADMIN_MODULE + `/sys-message/classified-messages`);
};

/**
 * 发布公告
 * @param params
 * @returns {*}
 */
export const publish = params => {
  return http.put(ADMIN_MODULE + `/sys-message/publish`, params);
};
/**
 * 用户消息
 * @param params
 * @returns {*}
 */
export const getUserMsgList = params => {
  return http.get(ADMIN_MODULE + `/sys-message/user-messages`, params);
};
/**
 * 已读消息
 * @param params
 * @returns {*}
 */
export const readMsg = params => {
  return http.put(ADMIN_MODULE + `/sys-message/message-status`, params, { loading: false });
};

/**
 * 删除用户消息
 * @param params
 * @returns {*}
 */
export const deleteUserMessage = params => {
  return http.delete(ADMIN_MODULE + `/sys-message/user-messages`, params);
};
